package com.rcadmin.busi.templateapi.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.rcadmin.busi.templateapi.dto.WebTemplateKeyReq;
import com.rcadmin.busi.templateapi.dto.WebTemplateKeyResp;
import com.rcadmin.busi.templateapi.service.WebBlockService;
import com.rcadmin.core.app.action.ResponseData;
import com.rcadmin.core.app.action.ResponseUtils;
import com.rcadmin.core.web.BaseAction;

/**
 * 内容管理接口服务
 * 
 * @author tanson lam
 * @create 2016年10月2日
 */
@RestController
public class BlockApiRest extends BaseAction {
	@Resource
	private WebBlockService webBlockService;

	/**
	 * 查找商店使用的模板页面配置的分组属性
	 */
	@RequestMapping(value = "/web/templateKey.op", method = RequestMethod.GET)
	@ResponseBody
	public void templateKey() {
		ResponseData responseData = null;
		try {
			WebTemplateKeyReq webTemplateKeyReq = getParamJson(WebTemplateKeyReq.class);
			List<WebTemplateKeyResp> keyList = webBlockService
					.listTemplateBlock(getLoginUserId(),
							webTemplateKeyReq.getTemplatePackageId(),
							webTemplateKeyReq.getTemplateName(),
							webTemplateKeyReq.getUrlReqParam());
			responseData = ResponseUtils.success("查询成功！");
			responseData.setResult(keyList);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			responseData = ResponseUtils.fail("查询失败！");
		}
		outJsonpResult(responseData);
	}
}
